package com.work.straighttalk.ui;

import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.widget.RelativeLayout;

import com.hyphenate.EMContactListener;
import com.work.straighttalk.bean.Notifyfriends;
import com.work.straighttalk.R;
import com.work.straighttalk.adapter.NewFriendsAdapter;
import com.work.straighttalk.app.BaseActivity;
import com.work.straighttalk.bean.User;
import com.work.straighttalk.presenter.NewFriendsPImpl;
import com.work.straighttalk.presenter.i.NewFriendsPI;
import com.work.straighttalk.ui.i.NewFriendsVI;

import java.util.List;

import butterknife.Bind;

/**
 * 申请与通知页面
 * Created by 肖江宏 on 16/3/4.
 */
public class NewFriendsActivity extends BaseActivity implements NewFriendsVI {

    @Bind(R.id.title)
    RelativeLayout title;
    @Bind(R.id.recyclerView)
    RecyclerView recyclerView;

    private NewFriendsAdapter adp;
    private List<User> users;
    public static NewFriendsPI newFriendsPI;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_new_friends);

        newFriendsPI = new NewFriendsPImpl(this);

        adp = new NewFriendsAdapter();
        recyclerView.setLayoutManager(new GridLayoutManager(this, 1));
        recyclerView.setAdapter(adp);

        newFriendsPI.refresh();
    }

    @Override
    public void sureFriends() {
        toast("已添加");
    }

    @Override
    public void updateItem(List<Notifyfriends> lists) {
        Log.d("NewFriendsActivity", "lists:" + lists.size());
        adp.loadData(lists);
        adp.notifyDataSetChanged();
    }

    @Override
    protected void onDestroy() {
        newFriendsPI.onDestroy();
        super.onDestroy();
    }


    public static class EMContactListeners implements EMContactListener {


        @Override
        public void onContactAdded(String s) {

        }

        @Override
        public void onContactDeleted(String s) {

        }

        @Override
        public void onContactInvited(String s, String s1) {
            newFriendsPI.validateUsername(s);
        }

        @Override
        public void onContactAgreed(String s) {

        }

        @Override
        public void onContactRefused(String s) {

        }
    }

}
